import java.io.IOException;
import java.net.MalformedURLException;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.DomNodeList;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlTable;
import com.gargoylesoftware.htmlunit.html.HtmlTableRow;


public class SampleWebTestForHiC {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		
		WebClient client = new WebClient(BrowserVersion.FIREFOX_3);
		try {
			HtmlPage p = client
					.getPage("http://hic.umassmed.edu/heatmap/heatmap.php");
			DomNodeList<HtmlElement> eList = p.getElementsByTagName("table");
			System.out.println(eList.size());
			HtmlTable t = (HtmlTable) eList.get(0);

			int count = 0;
			for (HtmlTableRow row : t.getRows()) {
				String theSRSId = row.getCells().get(1).getTextContent().trim();
				if (theSRSId.equals("")) {
					continue;
				}
				count++;

				System.out.println(theSRSId);
			}

			System.out.println("total account is " + count);
		} catch (FailingHttpStatusCodeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
